*------------------------------------------------------------------------------*
							*** FIGURE 2. SOEP ***
*------------------------------------------------------------------------------*

*This we cannot share
import excel using "${rawdata}soep/SOEP_remote_20210629.xlsx", clear first

*------------------------------------------------------------------------------*

***Prepare data
destring beta cih sd_outcome, replace

foreach var of varlist outcome treatment regression {

	replace `var' = trim(`var')

}

keep outcome beta cil cih

gen x = .

replace x 	= 1 	if outcome=="Incumbent"
replace x 	= 2 	if outcome=="Est_opp"
replace x 	= 3.5 	if outcome=="angry_dummy"
replace x 	= 4.5 	if outcome=="worried_dummy"
replace x 	= 5.5 	if outcome=="happy_dummy"
replace x 	= 6.5 	if outcome=="sad_dummy"
replace x 	= 7.5 	if outcome=="pca_dummy_components"
replace x 	= 8 	if outcome=="risk_selfreported"
replace x 	= 8.5 	if outcome=="risk_averse_dummy"
replace x 	= 9.5 	if outcome=="risk_loving_dummy"

keep if x!=.

sort x

xpose, clear varname

drop if _varn=="outcome" | _varn=="x"

rename v1 Incumbent
rename v2 Est_opp
rename v3 angry_dummy
rename v4 worried_dummy
rename v5 happy_dummy
rename v6 sad_dummy
rename v7 pca_dummy_components
rename v8 risk_selfreported
rename v9 risk_averse_dummy
rename v10 risk_loving_dummy


lab var  Incumbent 				"Identify with Government" 	
lab var  Est_opp 				"Identify with Opposition"
lab var  angry_dummy 			"Often Angry"
lab var  worried_dummy 			"Often Worried" 
lab var  happy_dummy 			"Often Happy"
lab var  sad_dummy 				"Often Sad"
lab var  pca_dummy_components 	"Negative Emotions (PCA)"
lab var  risk_averse_dummy 		"Risk averse"
lab var  risk_loving_dummy 		"Risk loving"
lab var  risk_selfreported 		"Willingness to take risk"


rename _varname rowname

mkmat Incumbent Est_opp angry_dummy worried_dummy happy_dummy sad_dummy pca_dummy_components risk_averse_dummy risk_loving_dummy, mat(beta) rown(rowname)

*------------------------------------------------------------------------------*

***Graph
coefplot ///
matrix(beta) , ci((2 3))   ///
xline(0, lc(cranberry)) xtitle("Effect of {bf:1}(PM10>20)") grid(none)  ///
	scheme(lean2) color(navy) ciopts(lc(navy)) graphregion(color(white)) ms(oh)

graph export "${outputs}figure2.png", replace width(3000)

*------------------------------------------------------------------------------*

clear

exit
